from enum import Enum


class StrategyType(Enum):
    VOLUME = ("交易量", "VOLUME")
    PRICE = ("交易价", "PRICE")
    NEWS = ("消息面", "NEWS")
    TIME_POINT = ("时间节点", "TIME_POINT")
    COMPREHENSIVE = ("综合", "COMPREHENSIVE")

    def __init__(self, description: str, code: str):
        self.description = description  # 中文描述
        self.code = code  # Code 标识

    def __str__(self):
        return f"{self.code}: {self.description}"
    
    @staticmethod
    def get_description_by_code(code: str) -> str:
        """
        根据 code 查询对应的 description。
        :param code: 策略类型的 code
        :return: 对应的 description，如果未找到则返回 '未知类型'
        """
        for item in StrategyType:
            if item.code == code:
                return item.description
        return "未知类型"